import { object } from "../../uni_modules/uview-plus/libs/function/test";
import http from "@/utils/http/hub";

/**
 * 抖音登录
 * wechatCode 微信登录code
 * telCode    微信获取手机号code
 * nickname   昵称
 * avatar     头像
 */
export const loginByWechat = (
  params,
  config = {
    custom: {
      auth: false,
      loading: false,
    },
  }
) => {
  const query = {
    douYinCode: params.wechatCode,
    dyTelCode: params.telCode,
    nickname: params.nickname,
    avatar: params.avatar,
  };
  const requestQuery = Object.assign(params, query);
  return http.post({
    url: `/access/loginByDouYin`,
    params: requestQuery,
    config,
  });
};

/**
 * 手机短信登录
 * douyincode 抖音登录code
 * nickname   昵称
 * avatar     头像
 * phone      手机号
 * code       验证码
 */
export const loginBySms = (
  params,
  config = {
    custom: {
      auth: false,
    },
  }
) => {
  const query = {
    douYinCode: params.wechatCode,
    nickname: params.nickname,
    avatar: params.avatar,
  };
  const requestQuery = Object.assign(params, query);
  return http.post({
    url: `/access/loginBySms`,
    params: requestQuery,
    config,
  });
};

/**
 * 刷新token
 */
export const refreshToken = (
  params,
  config = {
    custom: {
      auth: false,
      loading: false,
    },
  }
) => {
  return http.post({
    url: `/access/refreshToken`,
    params,
    config,
  });
};
